﻿using System.Text.Json.Serialization;

namespace Digitalmes.AvaloniaUI.Controls;

/// <summary>
/// LED 点
/// </summary>
public sealed class LedPoint : ObservableObject
{
    /// <summary>
    /// 圆直径
    /// </summary>
    public int Diameter { get; set; }

    /// <summary>
    /// 显示文本
    /// </summary>
    public string? Text { get; set; }

    /// <summary>
    /// 显示文本颜色
    /// </summary>
    public string? TextColor { get; set; }

    /// <summary>
    /// 显示文本字体大小
    /// </summary>
    public double? TextFontSize { get; set; }

    /// <summary>
    /// 索引编号
    /// </summary>
    public int Index { get; set; }

    /// <summary>
    /// 编号分组，默认为空。
    /// </summary>
    [NotNull]
    public string? Group { get; set; } = string.Empty;

    /// <summary>
    /// LED 初始化状态
    /// </summary>
    [JsonConverter(typeof(JsonStringEnumConverter))]
    public LedState State { get; set; } = LedState.Off;

    /// <summary>
    /// <see cref="LedState.Off"/> 状态颜色
    /// </summary>
    public string? OffColor { get; set; }

    /// <summary>
    /// <see cref="LedState.Good"/> 状态颜色
    /// </summary>
    public string? GoodColor { get; set; }

    /// <summary>
    /// <see cref="LedState.Bad"/> 状态颜色
    /// </summary>
    public string? BadColor { get; set; }

    private double _x;

    /// <summary>
    /// 画布 X 轴（左上顶点），控件拖动后会相应更改。
    /// </summary>
    public double X
    {
        get => _x;
        set => SetProperty(ref _x, value);
    }

    private double _y;

    /// <summary>
    /// 画布 Y 轴（左上顶点），控件拖动后会相应更改。
    /// </summary>
    public double Y
    {
        get => _y;
        set => SetProperty(ref _y, value);
    }
}
